/**
 * @author rdiazalbertini
 */
function drawStaff(ctx, clef) {
	ctx.clearRect(0, 0, 320, 315); // clear canvas
	var img = new Image();
	img.onload = function() {
		ctx.beginPath();
		ctx.fillRect(10, 225, 300, 2);
		ctx.fillRect(10, 185, 300, 2);
		ctx.fillRect(10, 145, 300, 2);
		ctx.fillRect(10, 105, 300, 2);
		ctx.fillRect(10, 65, 300, 2);
		ctx.closePath();
		if (clef == 1)
			ctx.drawImage(img, 0, 50);
		else
			ctx.drawImage(img, 0, 65);
	}
	if (clef == 1)
		img.src = 'images/treble_clef.png';
	else
		img.src = 'images/bass_clef_xl.png';

}

function upQuarter(ctx, yloc) {
	var x = 150;
	ctx.beginPath();
	// Create Body of note
	ctx.arc(x, yloc, 25, 0, Math.PI * 2, false);
	ctx.fill();
	ctx.fillRect(x + 19, yloc - 110, 6, 110);
	if (yloc == 265) {
		ctx.fillRect(x - 35, yloc, 70, 2);
	}

}

function downQuarter(ctx, yloc) {
	var x = 150;
	ctx.beginPath();
	// Create Body of note
	ctx.arc(x, yloc, 25, 0, Math.PI * 2, false);
	ctx.fill();
	ctx.fillRect(x - 25, yloc, 6, 110);
	if (yloc == 25) {
		ctx.fillRect(x - 35, yloc, 70, 2);
	}

}

function upQuarter2(ctx, yloc) {
	var x = 250;
	ctx.beginPath();
	// Create Body of note
	ctx.arc(x, yloc, 25, 0, Math.PI * 2, false);
	ctx.fill();
	ctx.fillRect(x + 19, yloc - 110, 6, 110);
	if (yloc == 265) {
		ctx.fillRect(x - 35, yloc, 70, 2);
	}

}

function downQuarter2(ctx, yloc) {
	var x = 250;
	ctx.beginPath();
	// Create Body of note
	ctx.arc(x, yloc, 25, 0, Math.PI * 2, false);
	ctx.fill();
	ctx.fillRect(x - 25, yloc, 6, 110);
	if (yloc == 25) {
		ctx.fillRect(x - 35, yloc, 70, 2);
	}

}
function sharp(ctx, yloc) {
	var x = 90;
	yloc = eval(yloc);
	Mojo.Log.info('In create Sharp: ' + yloc);
	ctx.beginPath();
	ctx.lineWidth = 8;
	ctx.moveTo(x, yloc + 25);
	ctx.lineTo(x + 30, yloc + 18);
	ctx.moveTo(x, yloc - 15);
	ctx.lineTo(x + 30, yloc - 23);
	ctx.stroke();

	ctx.beginPath();
	ctx.lineWidth = 2;
	ctx.moveTo(x + 10, yloc - 55);
	ctx.lineTo(x + 10, yloc + 60);
	ctx.moveTo(x + 20, yloc - 60);
	ctx.lineTo(x + 20, yloc + 55);
	ctx.stroke();

	ctx.closePath();

}
function randOrd() {
	return (Math.round(Math.random()) - 0.5);
}

// Interval
function getSemiToneNote(startNum, semiCount) {
	startNum = eval(startNum);
	semiCount = eval(semiCount);
	var newNum = startNum + semiCount;
	if (newNum >= 12) {
		newNum = newNum - 12;
	}
	return newNum;
}

function getIntervalNote(intNote, sClef, selNoteIndex) {
	if (intNote.indexOf("#") < 0) {
		for ( var z = selNoteIndex +1; z < trbNotes.length; z++) {
			objNote = trbNotes[z];
			if (objNote.key == intNote) {
				intNote = objNote;
				break;
			}
		}
	}else{
		tmpIntNote = intNote.substring(0,1);
		for ( var z = selNoteIndex+1; z < trbNotes.length; z++) {
			objNote = trbNotes[z];
			if (objNote.key == tmpIntNote) {
				intNote = objNote;
				break;
			}
		}
			
	}
	
	return intNote;

}


//TouchPad Testing from Geoff Gauchet
var myApp = {};

myApp.isTouchPad = function(){

    if(Mojo.Environment.DeviceInfo.modelNameAscii.indexOf("ouch")>-1) {

        return true;

}

if(Mojo.Environment.DeviceInfo.screenWidth==1024){ return true; }

if(Mojo.Environment.DeviceInfo.screenHeight==1024){ return true; }

 

return false;

};